package com.ruoyi.develop.factory.factoryLibraryProduct.service.impl;

import java.util.List;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import com.ruoyi.develop.factory.factoryLibraryProduct.mapper.FactoryLibraryProductMapper;
import com.ruoyi.develop.factory.factoryLibraryProduct.domain.FactoryLibraryProduct;
import com.ruoyi.develop.factory.factoryLibraryProduct.service.IFactoryLibraryProductService;

/**
 * 产成品库Service业务层处理
 *
 * @author lmm
 * @date 2024-11-06
 */
@Service
public class FactoryLibraryProductServiceImpl implements IFactoryLibraryProductService {
    @Resource
    private FactoryLibraryProductMapper factoryLibraryProductMapper;

    /**
     * 查询产成品库
     *
     * @param id 产成品库主键
     * @return 产成品库
     */
    @Override
    public FactoryLibraryProduct selectById(String id) {
        return factoryLibraryProductMapper.selectById(id);
    }

    /**
     * 查询产成品库列表
     *
     * @param entity 产成品库
     * @return 产成品库
     */
    @Override
    public List<FactoryLibraryProduct> selectList(FactoryLibraryProduct entity) {
        return factoryLibraryProductMapper.selectList(entity);
    }

    /**
     * 新增产成品库
     *
     * @param entity 产成品库
     * @return 结果
     */
    @Override
    public int insert(FactoryLibraryProduct entity) {
        if (StringUtils.isBlank(entity.getId())) {
            entity.setId(IdUtils.fastSimpleUUID());
        }
        entity.setCreateBy(SecurityUtils.getUsername());
        entity.setCreateTime(DateUtils.getNowDate());
        return factoryLibraryProductMapper.insert(entity);
    }

    /**
     * 修改产成品库
     *
     * @param entity 产成品库
     * @return 结果
     */
    @Override
    public int update(FactoryLibraryProduct entity) {
        entity.setUpdateBy(SecurityUtils.getUsername());
        entity.setUpdateTime(DateUtils.getNowDate());
        return factoryLibraryProductMapper.update(entity);
    }

    /**
     * 批量删除产成品库
     *
     * @param ids 需要删除的产成品库主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return factoryLibraryProductMapper.deleteByIds(ids);
    }

    /**
     * 删除产成品库信息
     *
     * @param id 产成品库主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return factoryLibraryProductMapper.deleteById(id);
    }
}
